/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * AddDecisionListItem.java
 *
 * Created on Apr 17, 2011, 10:29:58 PM
 */

package View;

import Module.Session;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.util.ArrayList;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JTextArea;

/**
 *
 * @author CCD gruppe 2
 */
public class AddDecisionListItemFrame extends javax.swing.JFrame {

    /** Creates new form AddDecisionListItem */
    public AddDecisionListItemFrame() {
        initComponents();
    }

    private javax.swing.JComboBox sessionComboBox;
    private javax.swing.JComboBox statusComboBox;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea decisionDescriptionTextArea;
    private DefaultComboBoxModel sessionComboBoxModel;
    private DefaultComboBoxModel statusComboBoxModel;
    private javax.swing.JButton closeDecisionListItemButton;
    private javax.swing.JButton saveDecisionListItemButton;



    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        sessionComboBox = new javax.swing.JComboBox();
        jLabel2 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        decisionDescriptionTextArea = new javax.swing.JTextArea();
        jLabel3 = new javax.swing.JLabel();
        statusComboBox = new javax.swing.JComboBox();
        sessionComboBoxModel = new DefaultComboBoxModel();
        statusComboBoxModel = new DefaultComboBoxModel();
        sessionComboBox.setModel(sessionComboBoxModel);
        statusComboBox.setModel(statusComboBoxModel);
        closeDecisionListItemButton = new javax.swing.JButton();
        saveDecisionListItemButton = new javax.swing.JButton();
        jLabel1.setText("Tilknytning:");
        statusComboBoxModel.addElement("Til beslutning");
        statusComboBoxModel.addElement("Besluttet");


        jLabel2.setText("Beskrivelse: ");

        decisionDescriptionTextArea.setColumns(20);
        decisionDescriptionTextArea.setRows(5);
        decisionDescriptionTextArea.setLineWrap(true);
        jScrollPane1.setViewportView(decisionDescriptionTextArea);

        jLabel3.setText("Status:");

        saveDecisionListItemButton.setText("Lagre");

        closeDecisionListItemButton.setText("Lukk");

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .add(saveDecisionListItemButton, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 160, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(18, 18, 18)
                        .add(closeDecisionListItemButton, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 182, Short.MAX_VALUE))
                    .add(layout.createSequentialGroup()
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jLabel2)
                            .add(jLabel3)
                            .add(jLabel1))
                        .add(30, 30, 30)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 252, Short.MAX_VALUE)
                            .add(sessionComboBox, 0, 252, Short.MAX_VALUE)
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, statusComboBox, 0, 252, Short.MAX_VALUE))))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(sessionComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel1))
                .add(18, 18, 18)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel2)
                    .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 161, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(20, 20, 20)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel3)
                    .add(statusComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 12, Short.MAX_VALUE)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(saveDecisionListItemButton)
                    .add(closeDecisionListItemButton))
                    .addContainerGap())
        );


        pack();
        setCenterPos(this);
    }// </editor-fold>

    private static void setCenterPos(JFrame frame) {
        Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
        int x = (int) ((screen.getWidth() - frame.getWidth()) / 2);
        int y = (int) ((screen.getHeight() - frame.getHeight()) / 2);
        frame.setLocation(x, y);
    }
    
    /**
     * A method that clears the input
     */
    public void clearInputt(){
        sessionComboBoxModel.removeAllElements();
        statusComboBoxModel.removeAllElements();
        decisionDescriptionTextArea.setText("");
    }

    /**
     * A method that adds sessions and projects to the combobox.
     * @param sessions
     * @param projectName
     */
    public void readyToRegister(ArrayList<Session> sessions,String projectName){
        statusComboBoxModel.removeAllElements();
        sessionComboBoxModel.removeAllElements();
        statusComboBoxModel.addElement("Til Besluttning");
        statusComboBoxModel.addElement("Besluttet");
        statusComboBoxModel.addElement("Avsluttet");
        sessionComboBoxModel.addElement(projectName);
        for(int i=0; i<sessions.size();i++){
            sessionComboBoxModel.addElement(sessions.get(i).getName());
        }
    }
    /*
     * Getters and setters
     */
    public JButton getCloseDecisionListItemButton() {
        return closeDecisionListItemButton;
    }

    public void setCloseDecisionListItemButton(JButton closeDecisionListItemButton) {
        this.closeDecisionListItemButton = closeDecisionListItemButton;
    }

    public JButton getSaveDecisionListItemButton() {
        return saveDecisionListItemButton;
    }

    public void setSaveDecisionListItemButton(JButton saveDecisionListItemButton) {
        this.saveDecisionListItemButton = saveDecisionListItemButton;
    }

    public JComboBox getSessionComboBox() {
        return sessionComboBox;
    }

    public void setSessionComboBox(JComboBox sessionComboBox) {
        this.sessionComboBox = sessionComboBox;
    }

    public DefaultComboBoxModel getSessionComboBoxModel() {
        return sessionComboBoxModel;
    }

    public void setSessionComboBoxModel(DefaultComboBoxModel sessionComboBoxModel) {
        this.sessionComboBoxModel = sessionComboBoxModel;
    }

    public JComboBox getStatusComboBox() {
        return statusComboBox;
    }

    public void setStatusComboBox(JComboBox statusComboBox) {
        this.statusComboBox = statusComboBox;
    }

    public DefaultComboBoxModel getStatusComboBoxModel() {
        return statusComboBoxModel;
    }

    public void setStatusComboBoxModel(DefaultComboBoxModel statusComboBoxModel) {
        this.statusComboBoxModel = statusComboBoxModel;
    }


    public JTextArea getDecisionDescriptionTextArea() {
        return decisionDescriptionTextArea;
    }

}
